<?php
$xmldb = new SimpleXMLElement(file_get_contents("database.xml"));
$sqldb = sqlite_open("database.sqlite");
$id = 0;
foreach($xmldb->pages->page as $page) {
  // page
  $query = "INSERT INTO pages (
  id,
  title,
  tags
) VALUES (
  $id,
  '".$page['title']."',
  '".$page['categories']."'
)";
  echo $query."\n";
  // revisions
  /*foreach($page->revision as $revision) {
    if(!$revision['ip'] == NULL) {
      $ip = "'".$revision['ip']."'";
    } else {
      $ip = "NULL";
    }
    $query = "INSERT INTO revisions (
  ip,
  author,
  pageid,
  time,
  body
) VALUES (
  $ip,
  '".$revision['author']."',
  $id,
  ".$revision['time'].",
  '".sqlite_escape_string($revision)."'
)";
    echo $query."\n";
    sqlite_query($db,$query);
  }*
  $id ++;
}
?>